package utils;


import com.shishi.tech.paipai.application.BaseApplication;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by Administrator on 2016/7/12.
 * 获取配置文件工具
 */
public class PropUtil {
    private String filePath = "";
    private Properties pros = new Properties();

    public PropUtil(String filePath) {
        this.filePath = filePath;
        this.load(filePath);
    }

    public void load(String filePath) {
        try {
            InputStream inputStream = BaseApplication.getInstance().getApplicationContext().getAssets().open(filePath);
            //InputStream inputStream = super.getClass().getClassLoader().getResourceAsStream(filePath);
            pros.load(inputStream);
        } catch (IOException ex) {
            System.out.println("file is not exist");
        }
    }

    public String get(String key) {
        return pros.getProperty(key);
    }

    public void set(String key, String value) {
        pros.setProperty(key, value);
    }
}
